package com.wyp168.leetcode;

public class MartixRecever {
    public static void main(String[] args) {
        int [][] map = {{1,2,3},{4,5,6},{7,8,9}};
        recever(map);
        for (int i = 0 ; i < 3; i ++) {
            for (int j = 0 ; j < 3; j ++) {
                System.out.print(map[i][j] + " ");
            }
            System.out.println();
        }
    }
    public static void recever(int[][] map) {
        //先将该数组上下两行交换位置
        for (int i = 0; i< map[0].length; i++) {
            int temp = map[0][i];
            map[0][i] = map[map.length-1][i];
            map[map.length-1][i] = temp;
        }
        //然后将数组沿主对角线方向调换位置
        for (int i = 0 ; i < map.length; i ++) {
            for (int j = i + 1; j < map[0].length; j++) {
                int temp = map[i][j];
                map[i][j] = map[j][i];
                map[j][i] = temp;
            }
        }
    }
}
